Live Chat

(Press the button and hold it to see :active!)

4.4 What to style

  1. Motivations

  2. Colors - Read all in CSS Colors.
  3. The CSS box model
    • List the four components.
    • Content - The related properties are ...
      • width
      • height
      • You can change the width and height of block-type elements with the above properties.
      • Can you change the width and height of an inline-type element, such as <a> and <span>?
        • You can use the display type, 'inline-block'.
        • Trial 1: Let's try to change the width and height of a <span> element.


    • Padding - The related properties are ...
      • padding
      • padding-top, padding-bottom, padding-left, padding-right
      • The above properties can be used for inline-type elements as well.
      • Here are examples - CSS Padding.
    • Border - The related properties are ...
      • border
      • border-width, border-style, border-color, border-radius
      • Here are examples - CSS Border.
    • Margin - The related properties are ...
      • margin
      • margin-top, margin-bottom, margin-left, margin-rigth
      • Here are examples - CSS Margin.
      • What margin value is used to horizontally center an element within its container?    'auto'; We will discuss the centering in detail later.
    • Background - The related properties are ...
      • background-color
      • background-image, background-repeat
      • Here are examples - CSS Background.
    • How about outside the borders? This area is called 'outline'. The related properties are ...
      • outline
      • outline-color, outline-style, outline-width
      • Here are examples - CSS Outlines.
      • Note. Outline does not change the margin space.
    • Trial 2: Let's try to change padding, border, margin, background color of a <div>. padding:10px; margin:10px, border: solid, 5px, Blue; background color: LightGreen


  4. What can you do with text?
    • color
    • Font related ...
    • text-align
    • text-indent
    • text-overflow
    • ...
    • Trial 3: Let's try to change text color and alignment.


  5. What happens if content overflows an element's box?
    • Read all in CSS overflow Property.
    • overfolow, overflow-y, overflow-x - Note that you should fix the height and width.
    • hidden, scroll, auto
  6. Click to see something different from the previous examples!
    • What do you need to use to display the box at the horizontal center and at the bottom?
    • How can you show and hide?
    • Is the expanded box displayed over all the others?
  7. Here is another very interesting example.
    • Menu for an application, TruQA:
        • Sign In
        • Join
        • Forgot Password
    • In the following sections, we will study show/hide, positioning, and overlapping.

  8. Learning outcomes
    • Use of all the CSS properties related to the box model